<h2>Loan Item</h2>
<hr/>
<p>Enter valid information into the following fields<br/>
NB: A valid Accession Number must be provided to enable submit button.
</p>
<center>
<!-- Subscriber information -->
<table>
<tr>
	<td colspan="2">
		<b>Name:</b> <?php echo $subscriber->first_name . ' ' . $subscriber->last_name; ?> <br />
		<b>Address:</b> <?php echo $subscriber->address1 . ', ' . $subscriber->post_code . ', ' . $subscriber->suburb; ?> <br / >
		<b>Expiry Date:</b>
		<?php
			if ($subscriber_paid)
			{
				echo $subscriber_paid->expiry_date;
				
				if ( $subscriber_paid->expiry_date < date('Y-m-d') )
					echo '<font color="red"> (EXPIRED) </font>';
			}
				
			else
				echo '<font color="red">No Payments Made</font>';
		?><br/>
		<b>Subscriber Status: </b> <?php echo $subscriber->subscriber_status; ?>
	</td>
</tr>
</table>
<br />
<div class="errorval"><?php echo validation_errors(); ?>
<?php echo $error; ?></div>
<br /><br />
<table>
<?php echo form_open('staff/loan_management/addLoan/' . $subscriber->subscriber_id); ?>
<?php echo form_hidden('subscriber_id', $subscriber->subscriber_id); ?>
<tr>
	<th align="right" width=30%>Accession Number:</th>
	<td><?php echo form_input('access_id', ''); ?></td>
</tr>
<tr>
	<td colspan="2">
		<p name="volume">Please Enter Accession Number</p> 
	</td>
</tr>
<tr>
	<th align="right">Loan Date:</th>
	<td><?php echo form_input('loan_date', date('Y-m-d')); ?></td>
</tr>
<tr>
	<th align="right">Due Date:</th>
	<td><?php echo form_input('due_date', date('Y-m-d', mktime(0, 0, 0, date('m') + 1, date('d'), date('Y')))); ?></td>
</tr>
<tr>
	<th align="right" class="tablehead">Actions</th>
	<td><?php echo form_submit('', 'Submit'); ?></td>
</tr>
<?php echo form_close(); ?>
</table>

</center>

<script type="text/javascript">
$(document).ready(function() {
		$( '[name=loan_date]' ).datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true });
		$( '[name=due_date]' ).datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true });

		$("input[type=submit]").attr("disabled", true);

		$("[name=access_id]").keyup( function(){
			$.post('<?php echo site_url('staff/jquery/getItemDetails'); ?>', $("[name=access_id]").serialize(), function(data) {
				if (data)
				{
					$('[name=volume]').html(data);
					$("input[type=submit]").attr("disabled", false);
				}
				else
				{
					$('[name=volume]').html('Invalid Accession Number');
					$("input[type=submit]").attr("disabled", true);
				}
			});
		});
});
</script>